<template>
  <div id="swiper">
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white" @change="onChange">
      <van-swipe-item v-for="(v, index) in imglist" :key="index">
        <img :src="v.img" alt="" />
      </van-swipe-item>
      <template #indicator>
        <div class="custom-indicator">{{ current + 1 }}/3</div>
      </template>
    </van-swipe>
  </div>
</template>

<script>
export default {
  data() {
    return {
      current: 0,
      imglist: []
    };
  },
  methods: {
    onChange(index) {
      this.current = index;
    },
  },
  mounted() {
    this.$http({
      url: " http://localhost:3000/ThingSwiperImg",
      method: "GET",
    }).then((res) => {
      this.imglist = res.data;
    })
}
}
</script>

<style scoped>
.my-swipe .van-swipe-item {
  width: 100%;
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  /* background-color: #39a9ed; */
  height: 23.4375rem;
}
img {
  width: 100%;
}
.custom-indicator {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 2px 5px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 0.625rem;
  color: white;
  width: 2rem;
  height: 1rem;
  text-align: center;
  line-height: 0.8rem;
}

</style>